<template>
    <div :class="props.class">
        <el-popover placement="left" v-model:visible="visible">
            <div class="del_confirm">
                <span>{{title}}</span>
                <div>
                    <span @click="visible = false">{{no}}</span>
                    <span @click="yesClick">{{yes}}</span>
                </div>
            </div>
            <template #reference>
                <u class="del_btn" @click="visible = true">{{text}}</u>
            </template>
        </el-popover>
    </div>
</template>

<script setup>
import { ref } from 'vue'
const emit = defineEmits(['yesClick'])

const props = defineProps({
    title: { type: String, default: "确定要删除吗？" },
    yes:   { type: String, default: "确认" },
    no:    { type: String, default: "取消" },
    text:  { type: String, default: "删除" },
    class: { type: String, default: "" }
})

let visible = ref(false)
let yesClick = e => {
    visible.value = false
    emit('yesClick', e)
}
</script>

<style scoped>
    .del_confirm div { text-align: right; font-size: 12px; padding-top: 10px; }
    .del_confirm div span:nth-child(1) { margin: 0 5px 0 0; }
    .del_confirm div span:nth-child(2) { color: red; }
    .del_btn { cursor: pointer; }
</style>